/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package bluetoothserver.dataStore;


import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;

/**
 *
 * @author phil
 */
public class SavedFileExporter {

    public void saveQuestion(File f,QuestionCollection questions){
        String path = f.getAbsolutePath();
        if(!f.exists()){
            path = path+".bq";
        }
        SavedWriter writer = new SavedWriter(path);
        ArrayList<Question> list = questions.getList();
        Iterator<Question> i = list.iterator();
                
        while(i.hasNext()){
            Question q = i.next();
            writer.writeLine(q.getQuestion());
            writer.writeLine(q.getType()+"");
            writer.writeLine(q.getCorrectAnswer()+"");
            String[] a = q.getAnswers();
            String s = "";
            for(int in = 0; in < a.length;in++){
                s = s+a[in]+",";
            }
            writer.writeLine(s);
        }
        writer.closeWriter();
    }
}
